var express = require('express');
var router = express.Router();
const path = require('path');

//获取动态空间数据接口
router.get('/list', function (req, res, next) {
    const dynamic = require(path.join(global.initUrl, 'mongodb/index')).dynamicList
    dynamic.find({}, function (err, data) {
        console.log(data)
        if (err) {
            throw new Error('查询失败')
        } else {
            res.send(data)
        }
    })

})

//获取课程表
router.get('/course', function (req, res, next) {
    const timetable = require(path.join(global.initUrl, 'mongodb/index')).timetable
    timetable.find({}, function (err,data) {
        res.send(data)
    })
})

//获取各科分数
router.get('/grades', function (req, res, next) {
    const grades = require(path.join(global.initUrl, 'mongodb/index')).grades
    grades.find({}, function (err, data) {
        res.send(data)
    })
})
module.exports = router;